import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsNumber, IsObject, IsOptional } from 'class-validator';

export class QueryPageDto<T> {
  @ApiProperty({
    description: '页数',
    default: 1,
  })
  @IsNumber()
  @IsNotEmpty()
  page: number;

  @ApiProperty({
    description: '分页数量',
    default: 10,
  })
  @IsNumber()
  @IsNotEmpty()
  size: number;

  @ApiProperty({
    description: '排序方式',
    required: false,
    default: 'desc',
  })
  @IsOptional()
  order: string;
  @ApiProperty({
    description: '排序字段',
    required: false,
    default: 'createdAt',
  })
  @IsOptional()
  sort: string;

  @IsObject()
  model: T;
}
